{include file="public/header" /}

<div class="page">
    <form id="user_form" enctype="multipart/form-data" method="post" action="{:url('Deliver/buyer_address_save',['order_id'=>$Request.param.order_id])}" >

        <table class="sc-default-table">
            <tbody>
                <tr class="noborder">

                </tr>

                <!-- 收货人 -->
                <tr class="noborder">
                    <td class="required w120"><label>{$Think.lang.member_address_receiver_name}:</label></td>
                    <td class="vatop rowform">
                        <input type="text" id="reciver_name" name="reciver_name"
                            value="{$address_info.reciver_name}" class="txt">
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 地区 -->
                <tr class="noborder">
                    <td class="required w120"><label>{$Think.lang.deliver_area}:</label></td>
                    <td class="vatop">
                        <div>
                            <!-- <span class="reciver_info_area">{$address_info.reciver_info.area}</span> -->
                            <input type="hidden" id="region" name="reciver_area" value="{$address_info.reciver_info.area}" />
                        </div>
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 街道地址 -->
                <tr class="noborder">
                    <td class="required w120"><label>{$Think.lang.member_address_address}:</label></td>
                    <td class="vatop rowform"><input type="text" id="reciver_street" name="reciver_street"
                            value="{$address_info.reciver_info.street}" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 收货人 -->
                <tr class="noborder">
                    <td class="required w120"><label>订购人:</label></td>
                    <td class="vatop rowform">
                        <input type="text" id="real_name" name="real_name"
                               value="{$address_info.reciver_info.real_name}" class="txt">
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 手机 -->
                <tr class="noborder">
                    <td class="required w120"><label>{$Think.lang.order_mobile}:</label></td>
                    <td class="vatop rowform">
                        <input type="text" id="reciver_mob_phone" name="reciver_mob_phone"
                            value="{$address_info.reciver_info.mob_phone}" class="txt">
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 座机 -->
                <tr class="noborder">
                    <td class="required w120"><label>{$Think.lang.deliver_landline}:</label></td>
                    <td class="vatop rowform">
                        <input type="text" id="new_tel_phone" name="reciver_tel_phone"
                            value="{$address_info.reciver_info.tel_phone}" class="txt">
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 身份证号 -->
                <tr class="noborder">
                    <td class="required w120"><label>身份证号:</label></td>
                    <td class="vatop rowform"><input type="text" id="id_card_no" name="id_card_no"
                            value="{$address_info.reciver_info.id_card_no}" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!-- 身份证正面照 -->
                <tr class="noborder">
                    <td class="required"><label for="">身份证反面照:</label></td>
                    <td class="vatop rowform">
                        {notempty name="$address_info.reciver_info.id_card_front"}
                            <input type="hidden" name="id_card_front" value="{$address_info.reciver_info.id_card_front}">
                            <span class="type-file-show">
                                <img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
                                <div class="type-file-preview"><img src="{$address_info.reciver_info.id_card_front}"></div>
                            </span>
                        {/notempty}
                        <span class="type-file-box">
                            <input name="id_card_front" type="file" class="type-file-file" id="id_card_front_file" size="30" >
                        </span>
                    </td>
                </tr>

                <!-- 身份证反面照 -->
                <tr class="noborder">
                    <td class="required"><label for="">身份证反面照:</label></td>
                    <td class="vatop rowform">
                        {notempty name="$address_info.reciver_info.id_card_back"}
                            <input type="hidden" name="id_card_back" value="{$address_info.reciver_info.id_card_back}">
                            <span class="type-file-show">
                                <img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
                                <div class="type-file-preview"><img src="{$address_info.reciver_info.id_card_back}"></div>
                            </span>
                        {/notempty}
                        <span class="type-file-box">
                            <input name="id_card_back" type="file" class="type-file-file" id="id_card_back_file" size="30" >
                        </span>
                    </td>
                </tr>

            </tbody>

            <tfoot>
                <tr class="tfoot">
                    <td colspan="15"><a href="JavaScript:void(0);" class="btn"
                            id="submitBtn"><span>{$Think.lang.sc_submit}</span></a></td>
                </tr>
            </tfoot>
        </table>
    </form>

    <script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>
    <script type="text/javascript">
        $(function () {

            var textButton = "<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />"
            $(textButton).insertBefore("#id_card_front_file");
            $("#id_card_front_file").change(function () {
                $("#textfield1").val($("#id_card_front_file").val());
            });

            var textButton = "<input type='text' name='textfield' id='textfield2' class='type-file-text' /><input type='button' name='button' id='button2' value='' class='type-file-button' />"
            $(textButton).insertBefore("#id_card_back_file");
            $("#id_card_back_file").change(function () {
                $("#textfield2").val($("#id_card_back_file").val());
            });

            $("#region").sc_region();

            $("#submitBtn").click(function () {
                if ($("#user_form").valid()) {
                    $("#user_form").submit();
                }
            });

            $('#user_form').validate({
                errorPlacement: function (error, element) {
                    error.appendTo(element.parent().parent().find('td:last'));
                },
                rules: {
                    reciver_name: {
                        required: true,
                    },
                    reciver_mobile: {
                        required: true,
                    },
                    region: {
                        checklast: true
                    },
                    reciver_street: {
                        required: true
                    },
                },
                messages: {
                    reciver_name: {
                        required: '收货人必填'
                    },
                    reciver_mobile: {
                        required: '收货人手机号必填',
                    },
                    region: {
                        checklast: '区域不完整'
                    },
                    reciver_street: {
                        required: '街道必填'
                    },
                }
            });
        });
    </script>
</div>
